﻿package com.wandian.model
{
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.http.UserData;
	import com.wandian.model.vo.*;
	import com.wandian.util.loader.LoadXML;

	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;

	import org.puremvc.as3.patterns.proxy.Proxy;

	class XMLDataProxy extends Proxy
	{
		private var _xmlLoader:LoadXML;
		public static const NAME:String="XMLDataProxy";

		function XMLDataProxy(param1:Object=null)
		{
			super(NAME, param1);
			//--程序一启动 ，就去加载资源
			this.loadData();
			return;
		} 

		private function loadData():void
		{
//            var xmlUrl:String = GameData.flashver["xml"] + "";
			this._xmlLoader=new LoadXML();
//			this._xmlLoader.loadByURLList([GameDat1a.flashUrl + "tip.xml", GameData.flashUrl + "config.xml", GameData.flashUrl + "swf.xml", GameData.flashUrl + "props.xml", GameData.flashUrl + "room.xml", GameData.flashUrl + "honor.xml", GameData.flashUrl + "common.xml", GameData.flashUrl + "face.xml", GameData.flashUrl + "lottery.xml"]);
			this._xmlLoader.loadByURLList([GameData.flashUrl + "data/tip.xml", GameData.flashUrl + "data/config.xml", GameData.flashUrl + "data/props.xml", GameData.flashUrl + "data/room.xml", GameData.flashUrl + "data/honor.xml", GameData.flashUrl + "data/common.xml", GameData.flashUrl + "data/face.xml",GameData.flashUrl + "data/swf.xml"]);
			this._xmlLoader.addEventListener(LoadXML.LOAD_XML_OK, this.loadXMLOK);
			return;
		} 

		private function loadXMLOK(event:Event):void
		{
			event.currentTarget.removeEventListener(LoadXML.LOAD_XML_OK, this.loadXMLOK);
			GameData.initTip(this._xmlLoader.getXML("tip"));
			GameData.initConfig(this._xmlLoader.getXML("config"));
			GameData.initSWF(this._xmlLoader.getXML("swf"));
			GameData.propXml=this._xmlLoader.getXML("props");
			GameData.roomXml=this._xmlLoader.getXML("room");
			GameData.honorXml=this._xmlLoader.getXML("honor");
			GameData.commonXML=this._xmlLoader.getXML("common");
			GameData.faceXML=this._xmlLoader.getXML("face");
//			GameData.lotteryXML=this._xmlLoader.getXML("lottery");
			sendNotification(CLZNoticeName.LOAD_XML_COMPLETE);//通知ApplicationMediator
			return;
		} 

		private function onProgress(event:ProgressEvent):void
		{
			var _loc_2:*=int(event.bytesLoaded / event.bytesTotal * 100);
			return;
		} 

		private function onError(event:IOErrorEvent):void
		{
			sendNotification(CLZNoticeName.LOAD_DATA_FAILED, "数据加载失败");
			return;
		} 

	}
}
